function promiseRace(promises: Promise<any>[]): Promise<any> {
    return new Promise((resolve, reject) => {
        promises.forEach(promise => {
            promise.then(res => {
                resolve(res)
            }, err => {
                reject(err)
            })
        })
    })
}

const p1 = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve(1)
    }, 2000);
})

const p2 = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve(2)
    }, 3000);
})

const p3 = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve(3)
    }, 1000);
})

promiseRace([p1, p2, p3]).then(res => {
    console.log(res)
})